package com.metis.document.parse.dialog.pipeline.impl;

import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.seg.Segment;
import com.hankcs.hanlp.seg.common.Term;
import com.metis.document.parse.dialog.pipeline.TextPostProcess;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 人名脱敏处理 （20240327 误杀较多，暂时注释掉）
 */
//@Slf4j
//@Component
//public class NameDesensitizeTextPostProcess implements TextPostProcess {
//    @Override
//    public String process(@NotNull String input) {
//        Segment segment = HanLP.newSegment();
//        // 启用词性标注
//        segment.enablePartOfSpeechTagging(true);
//        List<Term> termList = segment.seg(input.replaceAll("\\s+","###"));
//        StringBuffer stringBuffer = new StringBuffer();
//        for (Term term : termList) {
//            // 词
//            String str = term.word;
//            // 词性
//            String type = String.valueOf(term.nature);
//            if ("nr".equals(type)){
//                str = str.replaceAll(".","*");
//            }
//            stringBuffer.append(str);
//        }
//        String reStr = stringBuffer.toString().replaceAll("###"," ");
//
////        log.info("原始值: {} , 脱敏值: {}",  input, reStr);
//
//        return reStr;
//    }
//}
